int mosfetPin = 5;

void setup()
{  
  pinMode (mosfetPin, OUTPUT);
  digitalWrite(mosfetPin, LOW);  

}

void loop()
{

    for (int j = 0; j < 255; j += 10) {
       analogWrite (mosfetPin, j);
       delay (100);
    }
    delay(1000); // keep the motor rolling for one second  
    for (int j = 255; j >= 0; j -= 10) {
       analogWrite (mosfetPin, j);
       delay (100);
    }

  digitalWrite(mosfetPin, LOW);   
  delay (4000);

}
